package com.wutuo.roster.provider.dao;

import cn.apestar.core.base.GenericMapper;
import cn.apestar.core.base.MapperAnnotation;
import com.wutuo.roster.provider.domain.Parents;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * 服务关系表 Dao 层
 *
 * @author lvh
 * @version 1.0
 */

@MapperAnnotation public interface BaseParentsMapper extends GenericMapper<Parents, Long> {

    @Override @Delete({"delete from parents", "where id = #{id,jdbcType=BIGINT}"})
    int deleteByPrimaryKey(Long id);

    @Override
    @Insert({"insert into parents (", "roster_id,", "user_name,", "user_phone,", "user_type,",
        "create_by,", "create_date,", "update_by,", "update_date,", "cm_institution_id,",
        "remarks,", "del_flag", " )values(", "#{rosterId,jdbcType=BIGINT},",
        "#{userName,jdbcType=VARCHAR},", "#{userPhone,jdbcType=VARCHAR},",
        "#{userType,jdbcType=BIGINT},", "#{createBy,jdbcType=BIGINT},",
        "#{createDate,jdbcType=DATE},", "#{updateBy,jdbcType=BIGINT},",
        "#{updateDate,jdbcType=DATE},", "#{cmInstitutiond,jdbcType=VARCHAR},",
        "#{remarks,jdbcType=VARCHAR},", "#{delFlag,jdbcType=VARCHAR})"}) int insert(Parents record);

    @InsertProvider(type = BaseParentsSqlProvider.class, method = "insertSelective")
    int insertSelective(Parents record);

    @Override
    @Select({"select", "id,roster_id,", "user_name,", "user_phone,", "user_type,", "create_by,",
        "create_date,", "update_by,", "update_date,", "remarks,", "del_flag", "cm_institution_id",
        "from parents", "where id = #{id,jdbcType=BIGINT}"})
    @Results({@Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
        @Result(column = "roster_id", property = "rosterId", jdbcType = JdbcType.BIGINT),
        @Result(column = "user_name", property = "userName", jdbcType = JdbcType.VARCHAR),
        @Result(column = "user_phone", property = "userPhone", jdbcType = JdbcType.VARCHAR),
        @Result(column = "user_type", property = "userType", jdbcType = JdbcType.BIGINT),
        @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.BIGINT),
        @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.DATE),
        @Result(column = "update_by", property = "updateBy", jdbcType = JdbcType.BIGINT),
        @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.DATE),
        @Result(column = "remarks", property = "remarks", jdbcType = JdbcType.VARCHAR),
        @Result(column = "cm_institution_id", property = "cmInstitutiond", jdbcType = JdbcType.BIGINT),
        @Result(column = "del_flag", property = "delFlag", jdbcType = JdbcType.VARCHAR)})
    Parents selectByPrimaryKey(Long id);

    @Override
    @UpdateProvider(type = BaseParentsSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Parents record);

    @Override @Update({"update parents", "set ", "roster_id = #{rosterId,jdbcType=BIGINT},",
        "user_name = #{userName,jdbcType=VARCHAR},", "user_phone = #{userPhone,jdbcType=VARCHAR},",
        "user_type = #{userType,jdbcType=BIGINT},", "create_by = #{createBy,jdbcType=BIGINT},",
        "create_date = #{createDate,jdbcType=DATE},", "update_by = #{updateBy,jdbcType=BIGINT},",
        "update_date = #{updateDate,jdbcType=DATE},", "remarks = #{remarks,jdbcType=VARCHAR},",
        "del_flag = #{delFlag,jdbcType=VARCHAR}", "where id = #{id,jdbcType=BIGINT}"})
    int updateByPrimaryKey(Parents record);
}